﻿@using Orchard.ContentManagement;
@using Orchard.Core.Contents
@using Orchard.Utility.Extensions;
@{
    Script.Require("ShapesBase");
    ContentPart contentPart = Model.ContentPart;
}
@if (contentPart.HasPublished()) {
    @Html.ItemDisplayLink(T("View").Text, (ContentItem)Model.ContentPart.ContentItem)
    @T(" | ")

    if (contentPart.HasDraft()) {
        @Html.Link(T("Publish Draft").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = contentPart.ContentItem.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
        @T(" | ")

        if (Authorizer.Authorize(Permissions.PublishContent, contentPart)) {
            @Html.ActionLink(T("Preview").Text, "Preview", "Item", new {area = "Contents", id = ((ContentItem) Model.ContentPart.ContentItem).Id}, new {})
            @T(" | ")
        }
    }

    if (Authorizer.Authorize(Permissions.PublishContent, contentPart)) {
        @Html.Link(T("Unpublish").Text, Url.Action("Unpublish", "Admin", new {area = "Contents", id = contentPart.ContentItem.Id, returnUrl = Request.ToUrlString()}), new {itemprop = "UnsafeUrl"})
        @T(" | ")
    }
} else {
    if ( contentPart.HasDraft() ) {    
        @Html.ActionLink(T("Preview").Text, "Preview", "Item", new { area = "Contents", id = ((ContentItem)Model.ContentPart.ContentItem).Id }, new { })
        @T(" | ")
    }

    if (Authorizer.Authorize(Permissions.PublishContent, contentPart)) {
        @Html.Link(T("Publish").Text, Url.Action("Publish", "Admin", new {area = "Contents", id = contentPart.ContentItem.Id, returnUrl = Request.ToUrlString()}), new {itemprop = "UnsafeUrl"})
        @T(" | ")
    }
}